<template>
	<view>
		<form>
			<view class="cu-form-group">
				<view class="title">姓名</view>
				<text v-text="username"></text>
			</view>
			<view class="cu-form-group">
				<view class="title">地址</view>
				<text v-text="zone"></text>
			</view>
			<view class="cu-form-group">
				<view class="title">详细地址</view>
				<text v-text="location"></text>
			</view>
			<view class="cu-form-group">
				<view class="title">联系方式</view>
				<text v-text="telephone"></text>
			</view>
			<view class="cu-form-group">
				<view class="title">预约时间</view>
				<text v-text="reserve_time"></text>
			</view>
			<view class="cu-form-group">
				<view class="title">详情</view>
				<text v-text="detail"></text>
			</view>
			<view class="cu-form-group margin-top">
				<view class="title">备注</view>
				<text v-text="remark"></text>
			</view>
		</form>
		<view class="box margin-top">
			<view class="cu-bar btn-group">
				<button class="cu-btn bg-green shadow-blur round lg" @click="userReserved">接收订单</button>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				orderid:'',
				username: '',
				location: '',
				telephone: '',
				reserve_time: '',
				detail: '',
				remark: '',
				loc_id:'',
				zone:'',
				siteid:''
			}
		},
		onLoad(e) {
	        this.orderid = e.orderid;
			this.siteid=e.siteid
		},
		onShow(){
			this.$H.get('/order/orderdetail/get-order-detail/' + this.orderid).then(res => {
				let [err, result] = res;
				if (result.data.code == '200') {
					this.username = result.data.data.user_name;
					this.loc_id = result.data.data.user_location;
					this.telephone = result.data.data.user_tel;
					this.reserve_time = result.data.data.reserve_time;
					console.info(this.reserve_time)
					this.detail = result.data.data.detail;
					this.remark = result.data.data.remark;
				}
			})
			this.$H.get('/order/site/get-siteone/' + this.siteid).then(res => {
				let [err, result] = res;
				if (result.data.code == '200') {
					this.username = result.data.data.name;
					this.location = result.data.data.location;
					this.telephone = result.data.data.telephone;
					this.zone = result.data.data.zone;
				}
			})
		},
		computed: {
			
		},
		methods: {
			userReserved(){
				this.$H.put('/order/orders/user-reserved',{
					id:this.orderid,
					reserved_userid:this.$store.state.userInfo.id
				}).then(res=>{
					let [err,result] = res;
					if(result.data.code == '401'){
						uni.showModal({
							title:'错误提示',
							content:result.data.message,
							showCancel:false
						})
						return;
					}
					if(result.data.code == '200'){
						//this.$store.commit('alterUserInfo',result.data.data);
						uni.showModal({
							title:'成功',
							content:'操作成功',
							showCancel:false,
						})
					}
				})
			}
		}
	}
</script>

<style>
</style>
